package com.maiji.cloud.entities.login;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.maiji.cloud.entities.shopingmall.Goods;
import com.maiji.cloud.response.login.UploadImageResData;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

/**
 *  麦吉简介文章
 */
@NoArgsConstructor
@Data
@Accessors(chain=true)
@Table(name = "maiji_article")
public class MaijiArticle implements Comparable<MaijiArticle> {

    @TableId
    @ApiModelProperty(value="文章ID")
    @Column(name = "uu_id", type = MySqlTypeConstant.VARCHAR, length = 50, isKey = true)
    private String uuId;

    @ApiModelProperty(value="文章标题")
    @Column(name = "title", type = MySqlTypeConstant.VARCHAR)
    private String title; //

    @ApiModelProperty(value="文章简介")
    @Column(name = "desc", type = MySqlTypeConstant.VARCHAR)
    private String desc; //

    @ApiModelProperty(value="文章内容")
    @Column(name = "content", type = MySqlTypeConstant.LONGTEXT)
    private String content; //

    @ApiModelProperty(value="排序权重")
    @Column(name = "sort_weight", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer sortWeight; //

    @TableField(exist = false)
    private String realName;

    @TableField(exist = false)
    @ApiModelProperty(value="文章详情跳转地址")
    private String url = "/pages/maijiIntroDetail/maijiIntroDetail?uuId="; //

    public String getUrl () {
        if (StringUtils.isBlank(realName)) return null;
        return realName + url +uuId;
    }

    @TableField(exist = false)
    @ApiModelProperty(value="文章封面")
    private UploadImageResData img; //

    @TableField(exist = false)
    @ApiModelProperty(value="编辑类型：1删除，2修改属性")
    private Integer type; //

    @Override
    public int compareTo(MaijiArticle maijiArticle) {
        return maijiArticle.getSortWeight() - this.getSortWeight();
    }

}
